package command;

import entity.Student;

import java.util.List;
import java.util.Scanner;

public class CreateCommand implements Command {

    private final Scanner scanner = new Scanner(System.in);
    private Student _student = new Student();
    @Override
    public void execute(List<Student> students) {
        System.out.println("请输入一个新的学生信息：");
        Student student = new Student();
        student.setId(students.size()+1);
        System.out.print("姓名：");
        student.setName(scanner.nextLine());
        System.out.print("性别：");
        student.setGender(scanner.nextLine());

        students.add(student);
        _student = student;
    }

    @Override
    public void undo(List<Student> students) {
        students.remove(_student);
        System.out.println("成功撤销添加操作！删除的学生信息是:"+_student);
    }
}
